    valid = true;
	validForm = [false, false, false, false];
	
	submit  = document.getElementById("submit");
	/** cek ke-valid-an file */
	document.getElementById("file").addEventListener("blur", fileValidator, false);
	document.getElementById("file").addEventListener("keydown", fileValidator, false);
	document.getElementById("file").addEventListener("click", fileValidator, false);
	document.getElementById("deskripsi").addEventListener("focus", fileValidator, false);
	document.getElementById("kunci").addEventListener("focus", fileValidator, false);
	document.getElementById("tanggalFoto").addEventListener("focus", fileValidator, false);
	function fileValidator()
	{
		var ext = document.getElementById("file").value.match(/\.(.+)$/)[1];
		switch (ext) {
			case 'bmp' :
			case 'jpg' :
			case 'jpeg' :
			case 'png' :
				document.getElementById("fileValidator").innerHTML="";
				validForm[0] = true;
				break;
			default :
				document.getElementById("fileValidator").innerHTML="hanya menerima image file berekstensi .bmp, .jpg, .jpeg, .png";
				validForm[0] = false;
		}
		allowSubmission();
	}
	
	/** cek ke-valid-an deskripsi */
	document.getElementById("deskripsi").addEventListener("blur", deskripsiValidator, false);
	document.getElementById("deskripsi").addEventListener("keydown", deskripsiValidator, false);
	function deskripsiValidator()
	{
		if (validString(document.getElementById("deskripsi").value, /.{5,}/)) {
			document.getElementById("deskripsiValidator").innerHTML="";
			validForm[1] = true;
		} else {
			document.getElementById("deskripsiValidator").innerHTML="deskripsi minimal terdiri dari 5 karakter";
			validForm[1] = false;
		}
		allowSubmission();
	}
	
	/** cek ke-valid-an kunci */
	document.getElementById("kunci").addEventListener("blur", kunciValidator, false);
	document.getElementById("kunci").addEventListener("keydown", kunciValidator, false);
	function kunciValidator()
	{
		if (validString(document.getElementById("kunci").value, /.{3,}/)) {
			document.getElementById("kunciValidator").innerHTML="";
			validForm[2] = true;
		} else {
			document.getElementById("kunciValidator").innerHTML="kunci minimal terdiri dari 3 karakter";
			validForm[2] = false;
		}
		allowSubmission();
	}
	
	/** cek ke-valid-an tanggalFoto */
	document.getElementById("tanggalFoto").addEventListener("blur", tanggalFotoValidator, false);
	document.getElementById("tanggalFoto").addEventListener("keydown", tanggalFotoValidator, false);
	function tanggalFotoValidator()
	{
		if (validString(document.getElementById("tanggalFoto").value, /\d{4}-\d{2}-\d{2}/)) {
			if (isDate(document.getElementById("tanggalFoto").value)) {
				document.getElementById("tanggalFotoValidator").innerHTML="";
				validForm[3] = true;
			} else {
				document.getElementById("tanggalFotoValidator").innerHTML="tanggal tidak sahih";
				validForm[3] = false;
			}
		} else {
			document.getElementById("tanggalFotoValidator").innerHTML="format penanggalan adalah YYYY-MM-DD";
			validForm[3] = false;
		}
		allowSubmission();
	}
	function getDaysInYear (year) {
		for (var i = 1; i <= 12; ++i) {
			this[i] = 31;
			if ((i == 4) || (i == 6) || (i == 9) || (i == 11)) {
				this[i] = 30;
			}
			else if (i == 2) {
				this[i] = ((((year % 4 == 0) && ! (year % 100 == 0)) || (year % 400 == 0)) ? 29 : 28);
			}
		}
	
		return (this);
	}
	function isDate(strDate) {
		var strYear = strDate.substring(0, 4);
		var strMonth = strDate.substring(5, 7);
		var strDay = strDate.substring(8, 10);
		var year = parseInt(strYear);
		var month = parseInt(strMonth);
		var day = parseInt(strDay);
		var daysInMonth = getDaysInYear(year);
		if (year < 1) {
			return (false);
		}
		if ((month < 1) || (month > 12)) {
			return (false);
		}
		if ((day < 1) || (day > daysInMonth[month])) {
			return (false);
		}
	
		return (true);
	}
	
	function validString (str, reg) {
		return (reg.test(str));
	}
	
	function allowSubmission () {
		var valid = true;
		
		for (var i = 0; i < 4; ++i)
			if (! validForm[i])
				valid = false;
		
		if (valid)
			submit.removeAttribute("disabled");
	}
